from appium.webdriver.common.mobileby import MobileBy

from lagou.appium_exercise4.pages.base_page import BasePage


class EditMemberPage(BasePage):
    name_ele = (MobileBy.XPATH, "//*[contains (@text,'姓名')]/../android.widget.EditText")
    phoneno_ele = (MobileBy.XPATH, "//*[contains (@text,'手机')]/..//*[@text='手机号']")
    addparty_ele = (MobileBy.XPATH, "//*[@text='设置部门']")
    confirm_ele = (MobileBy.XPATH, "//*[@text='确定(1)']")
    save_ele = (MobileBy.XPATH, "//*[@text='保存']")
    def edit_member(self, name, phone_no):
        from lagou.appium_exercise4.pages.add_member_page import AddMemberPage
        # 输入姓名，手机
        self.find_and_send(*self.name_ele, name)
        self.find_and_send(*self.phoneno_ele,phone_no)
        # 设置部门，再次确认
        self.find_and_click(*self.addparty_ele)
        self.find_and_click(*self.confirm_ele)
        # 保存
        self.find_and_click(*self.save_ele)

        return AddMemberPage(self.driver)